package com.sesxh.project.knowledge.biz.util;


import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;

import com.sesxh.project.knowledge.biz.dto.ESContent;

public class ElasticUtil {
	
	 public static Map<String, Object> toDocument(ESContent esContent) {
		  
	        Map<String, Object> map = new HashMap<String, Object>();
	        if (esContent != null) {
	          map.put("id",esContent.getId());
	          map.put("title",esContent.getTitle() == null ? "" : esContent.getTitle());
	          map.put("content",esContent.getContent()==null?"":esContent.getContent() );
	          map.put("keyWords", esContent.getKeywords()==null?"":esContent.getKeywords());
	          map.put("cateId",esContent.getCateId());
	          map.put("userId",esContent.getUserId());
	          map.put("account",esContent.getAccount()); 
	          map.put("perName",esContent.getPerName()); 
	          map.put("createTime", new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(esContent.getCreateTime()==null?new Date():esContent.getCreateTime()));
	          map.put("updateTime", new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(esContent.getUpdateTime()==null?new Date():esContent.getUpdateTime()));
	          map.put("perName",esContent.getPerName()); 
	          map.put("status", esContent.getStatus());
	         
	        }

	        return map;
	    }
	 
    
    
}
